package cn.muqingfeng.api;

import android.content.Context;
import cn.muqingfeng.api.request.BaseGsonRequest;

import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

public class RequestHelper {
	public static final String UA = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36";
	private static RequestQueue sRequestQueue;

	private static synchronized RequestQueue getRequestQueue(Context context) {

		return sRequestQueue == null ? sRequestQueue = Volley.newRequestQueue(context, null, UA) : sRequestQueue;
	}

	public static final void startRequest(Context context, BaseGsonRequest<?> request) {
		ApiContext apiContext = ApiContext.create(context);
		request.setApiContext(apiContext);
		RequestQueue requestQueue = getRequestQueue(context);
		requestQueue.add(request);
	}

}
